package com.ruoyi.system.service.impl;

import java.util.List;
import java.util.UUID;

import com.ruoyi.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.system.mapper.INSURANCEMapper;
import com.ruoyi.system.domain.INSURANCE;
import com.ruoyi.system.service.IINSURANCEService;
import com.ruoyi.common.core.text.Convert;

/**
 * 保险Service业务层处理
 * 
 * @author ruoyi
 * @date 2021-11-09
 */
@Service
public class INSURANCEServiceImpl implements IINSURANCEService 
{
    @Autowired
    private INSURANCEMapper iNSURANCEMapper;

    /**
     * 查询保险
     * 
     * @param insuranceId 保险主键
     * @return 保险
     */
    @Override
    public INSURANCE selectINSURANCEByInsuranceId(String insuranceId)
    {
        return iNSURANCEMapper.selectINSURANCEByInsuranceId(insuranceId);
    }

    /**
     * 查询保险列表
     * 
     * @param iNSURANCE 保险
     * @return 保险
     */
    @Override
    public List<INSURANCE> selectINSURANCEList(INSURANCE iNSURANCE)
    {
        List<INSURANCE> insurances = iNSURANCEMapper.selectINSURANCEList(iNSURANCE);
        for (INSURANCE insurance : insurances) {
            System.out.println("</????.?>?>?>?>?"+insurance);
        }
        return iNSURANCEMapper.selectINSURANCEList(iNSURANCE);
    }

    /**
     * 新增保险
     * 
     * @param iNSURANCE 保险
     * @return 结果
     */
    @Override
    public int insertINSURANCE(INSURANCE iNSURANCE)
    {
        String s1 = DateUtils.dateTime();
        String uuid = UUID.randomUUID().toString();
        String s="staff"+s1+uuid.substring(uuid.length()-5,uuid.length()-1);
        iNSURANCE.setInsuranceId(s);
        return iNSURANCEMapper.insertINSURANCE(iNSURANCE);
    }

    /**
     * 修改保险
     * 
     * @param iNSURANCE 保险
     * @return 结果
     */
    @Override
    public int updateINSURANCE(INSURANCE iNSURANCE)
    {
        return iNSURANCEMapper.updateINSURANCE(iNSURANCE);
    }

    /**
     * 批量删除保险
     * 
     * @param insuranceIds 需要删除的保险主键
     * @return 结果
     */
    @Override
    public int deleteINSURANCEByInsuranceIds(String insuranceIds)
    {
        return iNSURANCEMapper.deleteINSURANCEByInsuranceIds(Convert.toStrArray(insuranceIds));
    }

    /**
     * 删除保险信息
     * 
     * @param insuranceId 保险主键
     * @return 结果
     */
    @Override
    public int deleteINSURANCEByInsuranceId(String insuranceId)
    {
        return iNSURANCEMapper.deleteINSURANCEByInsuranceId(insuranceId);
    }
}
